package vn.lumi.smarthome.network;

import android.content.Context;

public class LoginFeedback extends HCMsg{
	//constants
	public final static int LOGIN_SUCCESSFUL = 0x1A;
	public final static int WRONG_USER = 0xA1;
	public final static int HC_FULL = 0xAA; //There are already 2 devices with same user logged in, so no more login is allowed
	public final static int SESSION_DELETED = 0xA0;
	
	public final static int LENGTH = 5;
	
	//Attributes 
	private int Session_id = 0;
	private int User_id = 0;
	private int isUserValid = 0;
	private int HC_Config_ver = 0;;
	
	public LoginFeedback(){
		super(NetMessage.CMD_HC_LOGIN_FEEDBACK, 0, LENGTH);
	}
	
	@Override
	public void parseMessage(byte[] input, int length){
		//method for this class
		if(isCorrectFormat(input, length) == true){
			isUserValid = Byte2Unsigned(input[1]);
			Session_id = Byte2Unsigned(input[2]);
			User_id = Byte2Unsigned(input[3]);
			HC_Config_ver = Byte2Unsigned(input[4]);						
		}
	}
	
	

	public int getSid(){
		return Session_id;
	}
	
	public int getUid(){
		return User_id;
	}
	
	public int getUserValid(){
		return isUserValid;
	}
	
	public int getHCConfigVer(){
		return HC_Config_ver;
	}

	@Override
	public void doWhenReceived(Context context) {
		// TODO Auto-generated method stub
		
	}
		
}

